<template>
  <div>
    <div class="home-page">
      <div class="banner">
        <div class="container">
          <h1 class="logo-font">conduit</h1>
          <p>A place to share your knowledge.</p>
        </div>
      </div>

      <div class="container page">
        <div class="row">
          <div class="col-md-9">
            <div class="feed-toggle">
              <ul class="nav nav-pills outline-active">
                <li class="nav-item">
                  <a class="nav-link disabled" href="">Your Feed</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link active" href="">Global Feed</a>
                </li>
              </ul>
            </div>

            <div
              v-for="(item, index) in infoarr"
              :key="index"
              class="article-preview"
            >
              <div class="article-meta">
                <a href="profile.html"><img :src="item.author.image" /></a>
                <div class="info">
                  <a href="" class="author">{{ item.author.username }}</a>
                  <span class="date">January 20th</span>
                </div>
                <button class="btn btn-outline-primary btn-sm pull-xs-right">
                  <i class="ion-heart"></i> 29
                </button>
              </div>
              <a href="" class="preview-link">
                <h1>{{ item.body }}</h1>
                <p>{{ item.description }}</p>
                <span>Read more...</span>
              </a>
            </div>
          </div>

          <div class="col-md-3">
            <div class="sidebar">
              <p>Popular Tags</p>

              <div class="tag-list">
                <nuxt-link
                  v-for="(item, index) in tagarr"
                  :key="index"
                  class="tag-pill tag-default"
                  :to="{
                    query: {
                      tag: item,
                    },
                  }"
                  >{{ item }}</nuxt-link
                >
                <!-- <a href="" class="tag-pill tag-default">javascript</a>
            <a href="" class="tag-pill tag-default">emberjs</a>
            <a href="" class="tag-pill tag-default">angularjs</a>
            <a href="" class="tag-pill tag-default">react</a>
            <a href="" class="tag-pill tag-default">mean</a>
            <a href="" class="tag-pill tag-default">node</a>
            <a href="" class="tag-pill tag-default">rails</a> -->
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getAryicle } from "@/api/article.js";
import { tag } from "@/api/tag.js";
export default {
  name: "home",
  watchQuery: ["tag"],
  async asyncData() {
    const data = await Promise.all([getAryicle(), tag()]);
    console.log(data[0], 111111);

    return {
      infoarr: data[0].data.articles,
      tagarr: data[1].data.tags,
    };
    //  return {
    //      articles:articleArr.articles,
    //      articlesCount:articleArr.articlesCount,
    //  }
  },
    head() {
    return {
      title: "我就是一个tittle啊",
      meta: [
        {
          hid: "tag",
          name: "我就是一个tittle啊",
          content: "123",
        },
      ],
    };
  },
};
</script>

<style>
</style>